import gymnasium as gym

print(f"gymnasium版本：{gym.__version__}")  # latest: 1.2.2

# all environments in the registry
gym.pprint_registry(num_cols=1)

# Create environment
env = gym.make("BipedalWalker-v3", render_mode="human")
print(f"Action space: {env.action_space}")
print(f"Sample action: {env.action_space.sample()}")
print(f"Observation space: {env.observation_space}")
print(f"Sample observation: {env.observation_space.sample()}")

print(type(env.action_space.low))

# Reset environment to start a new episode
observation, info = env.reset()

episode_over = False
total_reward = 0

count = 0

while not episode_over:
    action = env.action_space.sample()
    count += 1
    observation, reward, terminated, truncated, info = env.step(action)

    total_reward += reward
    episode_over = terminated or truncated

print(f"Episode finished! Total reward: {total_reward}")
print(f"Episode over! count: {count}")
input("Press Enter to close...")  # 程序会在这里等待，终端不会立刻退出
env.close()